import request from '@/config/axios'

export interface MemberGroupVO {
  id: number
  name: string
  sort: number
  docDataScope: number
  dataScopeDocChannelIds: string
  type: number
  remark: string
}
export interface MemberGroupSimpleVO {
  id: number
  name: string
}
export interface PermissionAssignGroupContentScopeReqVO {
  roleId: number
  siteId: number
  docDataScope: number
  dataScopeChannelIds: number[]
}

// 查询会员组列表
export const getMemberGroupPage = async (params) => {
  return await request.get({ url: '/system/membergroup/page', params })
}

// 查询会员组（精简)列表
export const getSimpleGroupList = async (): Promise<MemberGroupSimpleVO[]> => {
  return await request.get({ url: '/system/membergroup/list-all-simple' })
}

// 查询会员组详情
export const getMemberGroup = async (id: number) => {
  return await request.get({ url: '/system/membergroup/get?id=' + id })
}

// 新增会员组
export const createMemberGroup = async (data: MemberGroupVO) => {
  return await request.post({ url: '/system/membergroup/create', data })
}

// 修改会员组
export const updateMemberGroup = async (data: MemberGroupVO) => {
  return await request.post({ url: '/system/membergroup/update', data })
}

// 删除会员组
export const deleteMemberGroup = async (id: number) => {
  return await request.post({ url: '/system/membergroup/delete', id: id })
}
// 赋予会员组内容权限
export const assignGroupContentScopeApi = async (data: PermissionAssignGroupContentScopeReqVO) => {
  return await request.post({ url: '/system/membergroup/assign-group-content-data-scope', data })
}
// 导出会员组 Excel
export const exportMemberGroupApi = async (params) => {
  return await request.download({ url: '/system/membergroup/export-excel', params })
}
